<template>
	<view>
		<view class="tuijianlist"><text>我的推荐人</text></view>
		<view class="top">
			<view class="user-info-box">
				<view class="left">
					<image class="portrait" src="/static/missing-face.png" v-if="!tuijianren.avatar"></image>
					<image class="portrait" :src="tuijianren.avatar" v-else></image>
					<view class="info-box">
						<text class="username">{{ tuijianren.nickname }}</text>
						<text class="levelname">{{ tuijianren.mobile }}</text>
					</view>
				</view>
				<!-- <view class="right">
					<text class="level0">{{ tuijianren.level }}</text>
				</view> -->
			</view>
		
		</view>
		<view class="tuijianlist b-t">
			<text>我推荐的人({{ fansList.length }}人)</text>
		</view>
		<view v-if="!fansList || fansList.length == 0" class="empty">
			<!-- <image src="/static/nobody.png" mode="aspectFit"></image> -->
			<view class="empty-tips">空空如也</view>
		</view>
		<view v-else v-for="(item, index) in fansList" :key="index">
			<view class="top">
				<view class="user-info-box">
					<view class="left">
						<image class="portrait" :src="item.avatar"></image>
						<view class="info-box">
							<text class="username">{{ item.nickname }}</text>
							<text class="levelname">{{ item.mobile }}</text>
						</view>
					</view>
					
				</view>
			</view>
		</view>
		<uni-load-more :status="loadingType"></uni-load-more>
		<!-- 底部 -->
		<!-- <view class="footer"><text class="submit" @click="share">邀请更多好友</text></view> -->
	</view>
</template>

<script>
import { mapState } from 'vuex';
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';		
export default {
	components: {
		uniLoadMore	
	},
	data() {
		return {
			fansList: [],
			tuijianren: { id: 0, avatar: '', nickname: '' },
			status: true,
			loadingType: 'more', //加载更多状态
			page:0
		};
	},
	onLoad(options) {
		this.loadData();
	},
	onReachBottom() {
		//判断是否最后一页
		
			this.loadData();
			},
	computed: {
		...mapState(['hasLogin', 'userInfo'])
	},
	methods: {
		loadData() {
			if(this.status){
				this.page=this.page+1;
			
			this.$api.post({
				url: '/wanlshop/User/fanslist',
				data:{
					page:this.page
				},
				success: res => {
					// this.goodsList=res
					let fansList = res.fanslist.data;
					let tuijianren = res.parents;
					console.log(res.fanslist.data)
					this.tuijianren = tuijianren;
					
					this.status = res.fanslist.data.length <10 ? false : true;
					console.log(this.status);
					this.fansList = this.fansList.concat(fansList);
					this.loadingType = res.fanslist.data.length <10 ? 'nomore' : 'more';
					// console.log(this.loadingType);
				}
			})
			}
			
		},
		
	}
};
</script>

<style lang="scss">
page {
	background-color: #ffffff;
	padding-bottom: 140rpx;
}
.tuijianlist {
	display: flex;
	flex-direction: row;
	align-items: center;
	padding: 20rpx;
	font-size: 32rpx;
	font-weight: bold;
	position: relative;
	&.b-t:after {
		left: 32rpx;
	}
	/* justify-content: center; */
}
/* 空白页 */
.empty {
	position: fixed;
	left: 0;
	top: 200;
	width: 100%;
	height: 100vh;
	display: flex;
	justify-content: center;
	flex-direction: column;
	align-items: center;
	background: #fff;
	image {
		width: 240upx;
		height: 160upx;
	}
	.empty-tips {
		display: flex;
		font-size: 30rpx;
		color: #ccc;
		.navigator {
			color: #ccc;
			margin-left: 16upx;
		}
	}
}
.top {
	height: 180rpx;
	margin: 0 10rpx 10rpx 10rpx;
	border-radius: 20rpx;
	background: rgb(255, 236, 204);
	.user-info-box {
		height: 180upx;
		display: flex;
		align-items: center;
		padding: 0 10rpx;
		.left {
			flex: 1;
			display: flex;
			.portrait {
				width: 130upx;
				height: 130upx;
				border: 5upx solid #fff;
				border-radius: 50%;
			}
			.info-box {
				height: 130upx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				.username {
					font-size: 32rpx;
					color: #2c466b;
					margin-left: 20upx;
					vertical-align: middle;
					font-weight: bold;
				}
				.levelname {
					font-size: 32rpx;
					color: #2c466b;
					margin-left: 20upx;
					vertical-align: middle;
				}
			}
		}
		.right {
			width: 160rpx;
			text-align: right;
			.level0 {
				color: #ffffff;
			}
		}
	}
	.split {
		height: 6rpx;
		background-color: #5c7a94;
		margin: 0 10rpx;
	}
	.tip {
		color: #2c466b;
		padding: 18rpx 10rpx;
	}
}
.footer {
	position: fixed;
	left: 0;
	bottom: 20rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100upx;
	.submit {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 80%;
		height: 100%;
		color: #dfcd87;
		font-size: 32rpx;
		border-radius: 50rpx;
		background: rgb(255, 236, 204);
		.btna {
			margin-left: 10rpx;
		}
	}
}
</style>
